package com.mjf.spark.day02

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark06_Transformation_map {
  def main(args: Array[String]): Unit = {

    // 创建SparkConf配置文件
    val conf = new SparkConf().setMaster("local[*]").setAppName("Spark06_Transformation_map")
    // 创建SparkContext对象
    val sc = new SparkContext(conf)

    val rdd: RDD[Int] = sc.makeRDD(List(1, 2, 3, 4), 2)

    println("原分区个数：" + rdd.partitions.size)

    val newRDD: RDD[Int] = rdd.map(_ * 2)   // 分区个数不变

    println("新分区个数：" + newRDD.partitions.size)

    newRDD.collect().foreach(println)

    // 关闭连接
    sc. stop()

  }
}
